#pragma once

#include <string>

#include "RelationshipArgumentType.h"
#include "ConstraintTableType.h"

/*!
 ConstraintEntry is the data structure containing information in the format
 ConstraintType - Argument 1 - Argument 2 - Argument Type 1 - Argument Type 2 - Argument Attr 1- Argument Attr 2
*/ 
struct ConstraintEntry {
	static const int MAX_ARGUMENTS = 2;

	ConstraintType constraintType; // The type of constraint (with_string / with_integer)
	std::string constraintArguments[MAX_ARGUMENTS]; // The main arguments (synonyms) of the constraints being provided (e.g. p in p.procName)
	RelationshipArgumentType constraintArgumentTypes[MAX_ARGUMENTS]; // The types of the arguments of the relationship being queried (e.g. SYNONYM_ASSIGN or INTEGER, etc.)
	ConstraintAttrType constraintAttrTypes[MAX_ARGUMENTS]; // The types of the attributes for the constraint argument
	int numberOfArguments; // The number of arguments there are for this particular constraint relationship clause.
	
	bool operator== (const ConstraintEntry &c) const {
		if (numberOfArguments!=c.numberOfArguments || constraintType!=c.constraintType) return false;
		bool check = true;
		for (int i = 0; i<=1; i++) {
			if (constraintArguments[i].compare(c.constraintArguments[i]) !=0
			||  constraintArgumentTypes[i]!=c.constraintArgumentTypes[i]) check = false;
		}
		if (check) return true;
		else {
			check = true;
			for (int i = 0; i<=1; i++) {
				if (constraintArguments[i].compare(c.constraintArguments[1-i]) !=0
					||  constraintArgumentTypes[i]!=c.constraintArgumentTypes[1-i]) check = false;
			}
			return check;
		}		
	}
};

